<div class="p-2">
    <Create />
    <Editor :selects="selectedRows" />
    <Remove :selects="selectedRows" />
    <div class="row">
        <div class="col-12">
            <div class="page-toolbar pt-0 pl-0 pr-0">
                <div class="loading-layer" v-if="loading"></div>
                <button type="button" class="btn btn-dark" @click="tableData()" :disabled="loading">
                    <i class="mdi mdi-refresh align-middle"></i>
                </button>
                <div class="form-group">
                    <select class="form-control custom-select" v-model="searchField" @change="tableData()">
                        <option value="username">用户名</option>
                        <option value="resource">资源</option>
                        <option value="resource_type">资源类型</option>
                        <option value="operation">操作</option>
                    </select>
                </div>
                <div class="form-group">
                    <input class="form-control" placeholder="搜索日志" @keydown.13="tableData()" v-model="search" />
                </div>
            </div>
            <a-table
                class="text-norwap"
                :scroll="{ x: true }"
                :columns="table.cols"
                :dataSource="table.rows"
                :pagination="pagination"
                :loading="loading"
                :locale="locale"
                :rowKey="records => records.id"
                :rowSelection="{ onChange: tableOnSelect, selectedRowKeys: selectedRowKeys, }"
                @change="tableChange"
            >
                <template slot="resource" slot-scope="resource, row">
                    <router-link :to="{
                        name: 'repos-detail',
                        params: {
                            project: resource.split('/')[0],
                            repo: resource.split('/').slice(1).join('/').split(':')[0]}
                        }"
                        v-if="row.resource_type == 'artifact'"
                    >{{ resource }}</router-link>
                    <span v-else>{{ resource }}</span>
                </template>
                <template slot="resource_type" slot-scope="resource_type">
                    <span class="text-muted">{{ resource_type }}</span>
                </template>
                <template slot="op_time" slot-scope="op_time">{{ op_time | toLocalTime }}</template>
            </a-table>
        </div>
    </div>
</div>
